package com.xiangxiao.rpan.storage.dto;

import cn.hutool.core.util.StrUtil;
import com.xiangxiao.rpan.storage.utils.StringUtil;
import lombok.Data;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/12/26 14:44
 */
@Data
public class FileQueryDto {
  private String storageKey;

  private String path;

  private String password;

  private String orderBy;

  private String orderDirection;

  public void handleDefaultValue() {
    if (StrUtil.isEmpty(path)) {
      path = "/";
    }
    if (StrUtil.isEmpty(orderBy)) {
      orderBy = "name";
    }
    if (StrUtil.isEmpty(orderDirection)) {
      orderDirection = "asc";
    }

    // 自动补全路径, 如 a 补全为 /a/
    path = StringUtil.concat(path);
  }

}
